@extends('host.custom.common.common')
@section('c-head')
    <script>
        var PAGE_DATA = {
            logo: "{{ $goods->brand->logo }}",
            modalCategoryData: undefined,
            modalBrandData: undefined,
            actionUrlB: "#bbb",
            actionUrlS: "#sss",
            addrDefault: {
                province_id: "{{ $goods->province_id }}",
                city_id: "{{ $goods->city_id }}",
                county_id: "{{ $goods->county_id }}",
            }, // 默认: undefined; 如果通过"编辑"跳转至本页面，则有值。
            userAgreementUrl: "#120",
            supplyAgreementUrl: "#122",
            specIds : [{{ $goods_specs }}]
        };
    </script>
    @stop
    @section('body')
            <!-- top_test -->
    <div id="top_test"></div>

    <!-- web_logo_search -->
    <div id="web_logo_search"></div>

    <!-- comm_nav -->
    <div id="comm_nav"></div>

    <div class="com-w mt20">
        <div class="wrapper clearfix">
            <div class="w220 mr20 comm-left-menu">
                <div class="menu-top-title">供应商中心</div>
                <div id="leftmenuitems"></div>
            </div>
            @if(count($errors) > 0)
                @foreach($errors->all() as $error)
                    <p>{{ $error }}</p>
                @endforeach
            @endif
            <div class="w960 comm-main">
                <div class="main-release clearfix">
                    <div class="main-release-nav">您当前的位置：首页 > 供应商中心</div>
                    <div class="main-release-title">
                        <span class="icons"></span>
                        <span class="release-title-h3 f16">编辑商品</span>
                    </div>
                    <div class="main-release-from">
                        <div class="back-adm-list">
                            <a href="{{ route('account.goods.index') }}" class="btn btn-default btn-100x30">返回管理列表</a>
                        </div>
                        <form id="supplier_center" action="{{ route('account.goods.update', $goods->id) }}"
                              method="post" enctype="multipart/form-data" class="clearfix">
                            {{ csrf_field() }}
                            <input type="hidden" name="_method" value="PUT">

                            <div class="add-classify clearfix">
                                <ul class="clearfix">
                                    <li class="current-left lh40">供采分销授权商品：</li>
                                    <li class="current-right text">
                                        <label for="grant_status" style="color: #FF500B;line-height: 40px;">
                                            <input type="checkbox" id="grant_status"
                                                   {{ $goods->grant_status ==1 ? 'checked' : '' }} name="grant_status"
                                                   value="1" text="(勾选此项商品需要采购关系授权后才能查看批发价格以及采购交易)">(勾选此项商品需要采购关系授权后才能查看批发价格以及采购交易)</label>
                                    </li>
                                    <li class="current-left">商品分类：</li>
                                    <li class="current-right">
                                        <select id="class_id" name="class_id">
                                            <option value="">请选择</option>
                                            @include('admin.site.category.category-list', ['categories' => $goods_categories, 'level' => 0, 'select' => old('class_id', $goods->class_id)])
                                        </select>
                                    </li>
                                    <li class="current-left">本店分类：</li>
                                    <li class="current-right">
                                        <select id="category_id" name="category_id">
                                            <option value="">请选择</option>
                                            @include('admin.site.category.category-list', ['categories' => $store_categories, 'level' => 0, 'select' => old('category_id', $goods->category_id)])
                                        </select>
                                        <a class="btn btn-warn btn-70x30 add-cla" style="display: none;">新增分类</a>
                                        <a style="display: none;">可以从属于多个本店分类</a>
                                    </li>
                                </ul>
                            </div>

                            <div class="fl clearfix">
                                <div class="add-upload upload-img" id="regist-elec-docs">
                                    <div class="img clearfix">
                                        <img src="{{ $goods->cover() }}">
                                    </div>
                                    <input type="file" value="" name="img[]" class="mt10 ml10" />
                                    <p class="mt10 tc" style="color: #888">支持jpeg和静态的gif格式图片，不支持gif动画图</p>
                                </div>
                            </div>
                            <div class="supplier-mian fl" style="width: 600px;">
                                <div class="clearfix mt25">
                                    <div class="add-right-l ">
                                        <span class="f-red">*</span>
                                        <label for="name" class="f14 tr">商品名称：</label>
                                    </div>
                                    <div class="add-right-r">
                                        <input type="text" id="name" name="name" value="{{ $goods->name }}"></div>
                                </div>
                                <div class="clearfix mt25">
                                    <div class="add-right-l">
                                        <span class="f-red">*</span>
                                        <label for="brand-btn" class="f14 tr">选择商品品牌：</label>
                                    </div>
                                    <div class="add-right-r">
                                        <a class="choose" href="javascript:void(0)" id="brand-btn" name="brand-btn">选择商品品牌</a>
                                    </div>
                                </div>
                                <div class="clearfix mt25" id="choose_banner" style="display: none">
                                    <div class="add-right-l">
                                        <span class="f-red">*</span>
                                        <label for="chose_banner" class="f14 tr">已选品牌：</label>
                                    </div>
                                    <div class="add-right-r">
                                        <span class="w240x100 " id="imgsrc"></span>
                                        <input name="brand_id" id="chose_banner" type="hidden"
                                               value="{{ $goods->brand_id }}"/>
                                    </div>
                                </div>
                                <div class="clearfix mt25">
                                    <div class="add-right-l">
                                        <span class="f-red">*</span>
                                        <label for="original_price" class="f14 tr">批发价：</label>
                                    </div>
                                    <div class="add-right-r lh32">
                                        <div class="lh32">
                                            <input type="text" id="original_price" name="original_price"
                                                   value="{{ $goods->original_price }}">（元）人名币
                                        </div>
                                    </div>
                                </div>
                                <div class="clearfix  mt25">
                                    <div class="add-right-l">
                                        <span class="f-red">*</span>
                                        <label for="stock" class="f14 tr">库存：</label>
                                    </div>
                                    <div class="add-right-r lh32">
                                        <input type="text" id="stock" name="stock" value="{{ $goods->stock }}">
                                    </div>
                                </div>
                                <div class="clearfix  mt25">
                                    <div class="add-right-l">
                                        <span class="f-red">*</span>
                                        <label for="release_address" class="f14 tr">发布地区：</label>
                                    </div>
                                    <div class="add-right-r lh32">
                                        <select id="province_id" name="province_id"></select>
                                        <select id="city_id" name="city_id"></select>
                                        <select id="county_id" name="county_id"></select>
                                    </div>
                                </div>
                                <div class="clearfix  mt25">
                                    <div class="add-right-l">
                                        <span class="f-red">*</span>
                                        <label for="minimum_order" class="f14 tr">起订量：</label>
                                    </div>
                                    <div class="add-right-r lh32">
                                        <input type="text" id="minimum_order" name="minimum_order"
                                               value="{{ $goods->minimum_order }}"></div>
                                </div>
                                <div class="clearfix  mt25">
                                    <div class="add-right-l">
                                        <span class="f-red">*</span>
                                        <label for="cn" class="f14 tr">货号：</label>
                                    </div>
                                    <div class="add-right-r lh32">
                                        <input type="text" id="cn" name="cn" value="{{ $goods->cn }}"></div>
                                </div>
                                <div class="clearfix  mt25">
                                    <div class="add-right-l">
                                        <span class="f-red">*</span>
                                        <label for="weight" class="f14 tr">单位：</label>
                                    </div>
                                    <div class="add-right-r lh32 f14">
                                        <input type="text" id="weight" name="unit" value="{{ $goods->unit }}">
                                    </div>
                                </div>
                                <div class="clearfix  mt25">
                                    <div class="add-right-l">
                                        <span class="f-red">*</span>
                                        <label for="display" class="f14 tr">展示权限：</label>
                                    </div>
                                    <div class="add-right-r lh32">
                                        <select id="display" name="display" style="width: 240px;">
                                            <option value="1" {{ $goods->display ==1  ? 'selected' : '' }}>所有人可见
                                            </option>
                                            <option value="2" {{ $goods->display ==2  ? 'selected' : '' }}>自己可见</option>
                                            <option value="3" {{ $goods->display ==3  ? 'selected' : '' }}>其它</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="clearfix  mt25" style="" id="this_from">
                                    <div class="spec-title f14 ml50">规格</div>
                                    <div class="spec-main">
                                        <span class="btn btn-warn btn-144x32 " id="open_spec1">开启规格</span>
                                        <span class="btn btn-warn btn-144x32 " id="reopen_spec" style="display:none;">打开规格</span>
                                        <div class="spec-text tc">您最多可以添加2种商品规格，如商品没有规格则不用添加。</div>
                                    </div>
                                    <div id="specs-form" class="keep-table" style="display: none;"></div>

                                </div>
                                <div class="clearfix  mt25">
                                    <div class="add-right-l">
                                        <span class="f-red">*</span>
                                        <label for="sell_status" class="f14 tr">是否上架：</label>
                                    </div>
                                    <div class="add-right-r lh32 radio-yes-no">
                                        <div class="fl">
                                            <label for="sell_status_1" class="lh32">
                                                <input type="radio" value="1" name="sell_status"
                                                       id="sell_status_1" {{ $goods->sell_status == 1  ? 'checked' : '' }}/>是</label>
                                        </div>
                                        <div class="fl ml10">
                                            <label for="sell_status_0" class="yes lh32">
                                                <input type="radio" value="0" name="sell_status"
                                                       id="sell_status_0" {{ $goods->sell_status == 0  ? 'checked' : '' }}/>否</label>
                                        </div>
                                    </div>
                                </div>

                                <div class="clearfix  mt25">
                                    <div class="add-right-l">
                                        <span class="f-red">*</span>
                                        <label for="shop_inventory" class="f14 tr">推荐：</label>
                                    </div>
                                    <div class="add-right-r lh32 radio-yes-no">
                                        <div class="fl">
                                            <label for="recommend_status_1" class="lh32">
                                                <input type="radio" name="recommend_status" id="recommend_status_1"
                                                       value="1" {{ $goods->recommend_status == 1  ? 'checked' : '' }}/>是</label>
                                        </div>
                                        <div class="fl ml10">
                                            <label for="recommend_status_0" class="yes lh32">
                                                <input type="radio" name="recommend_status" id="recommend_status_0"
                                                       value="0" {{ $goods->recommend_status == 0  ? 'checked' : '' }}/>否</label>
                                            <span class="f14 lh32 c-888">被推荐的商品会显示在店铺首页</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div>
                                <style type="text/css">
                                    #edui1_bottombar{display: none}
                                    .error{line-height: 32px}
                                </style>
                                <div class=" ml20" style="width: 925px;height: 420px;float: left;">
                                    <textarea id="container" name="detail">{{ $goods->detail }}</textarea>
                                </div>
                                <div class="clearfix fl tc mt20" style="width: 100%">
                                    <input type="submit" value="提交" class="w240x42 btn-important mb20"
                                           style="  margin-left: 345px;">
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- foot_nav -->
    <div id="foot_nav"></div>

    <div id="bottom_main"></div>
    <!--开启规格-->
    <script type="text/template" id="edit-spec-templ">
        <div class="dialog-div">
            <div class="dia-spec-title c-yer lh32 ml25">
                您最多可以添加五种规格（如：重量和包装等），规格名称可以自定义，
                如只有一项规格另外的留空。
            </div>
            <div class="dia-spec-tab">
                <div class="head">
                    <ul id="spec-title">
                        <li><input name="spec_first_name" type="text" /></li>
                        <li><input name="spec_second_name" type="text" /></li>
                        <li><input name="spec_third_name" type="text" /></li>
                        <li><input name="spec_forth_name" type="text" /></li>
                        <li><input name="spec_fifth_name" type="text" /></li>
                        <li>价格</li>
                        <li>库存</li>
                        <li class="number">货号</li>
                        <li class="operate">操作</li>
                    </ul>
                </div>
                <div class="spec-tab-main clearfix" id="add_spec_1"></div>
            </div>
            <div class="spec-tab-bottom1 clearfix">
                <div class="ml50 lh40">

                    <a href="javascript:void(0)" id="add_spec">
                        <i class="icon-plus" style="margin-right: 10px; color: #ff500b;" ></i>添加新的规格属性</a>
                </div>
            </div>

            <div class="dia-spec-btn tc">
                <span id="sel-keep-btn" class="btn btn-warn btn-w140x40 mt25 mb25 ">保存规格</span>
            </div>
        </div>
    </script>


    <script type="text/template" id="good-spec-templ">
        <% _.each(obj, function(specItem){ %>
        <ul class="disnone clearfix" >
            <li>
                <input data-type="spec-id" name="spec_id[]" type="hidden" value="<%=specItem.id %>" />
                <input data-type="spec-1" name="spec_first[]" type="text" value="<%=specItem.spec_1 %>" /></li>
            <li>
                <input data-type="spec-2" name="spec_second[]" type="text" value="<%=specItem.spec_2 %>" /></li>
            <li>
                <input data-type="spec-3" name="spec_third[]" type="text" value="<%=specItem.spec_3 %>" /></li>
            <li>
                <input data-type="spec-4" name="spec_forth[]" type="text" value="<%=specItem.spec_4 %>" /></li>
            <li>
                <input data-type="spec-5" name="spec_fifth[]" type="text" value="<%=specItem.spec_5 %>" /></li>
            <li>
                <input data-type="price" name="spec_original_price[]" type="text" value="<%=specItem.price %>" /></li>
            <li>
                <input data-type="stock" name="spec_stock[]" type="text" value="<%=specItem.stock %>" /></li>
            <li class="number">
                <input data-type="articleNum" name="spec_cn[]" type="text" value="<%=specItem.articleNum %>" /></li>
            <li class="operate">
                <span><i class="icon-arrow-up"></i></span>
                <span><i class="icon-arrow-down"></i></span>
                <span><i class="icon-remove"></i></span>
            </li>
        </ul>
        <% }); %>
    </script>

    <script type="text/template" id="addr-option-templ">
        <option value="">请选择</option>
        <% _.each(obj, function(item){ %>
        <option value="<%=item.code %>">
            <%=item.text %></option>
        <% }); %></script>

    <script type="text/template" id="classify-templ">
        <option value="">请选择</option>
        <% _.each(obj, function(item){ %>
        <option value="<%=item.code %>">
            <%=item.text %></option>
        <% }); %></script>

    <script type="text/template" id="item-template">
        <div class='dialog-div'>
            <div class='regist-left-box mr10'>
                <% var tmpIdx = 0; %>
                <% _.each(obj, function(item){%>
                <div class='info-item' id='info-item-title-<%=tmpIdx %>' >
                    <div class='content-box'>
                        <%=item.categTitle%></div>
                    <div class='icon-box'> <i class='icon-angle-right'></i>
                    </div>
                </div>
                <% tmpIdx++ %>
                <% });%></div>
            <div class='regist-right-box' id="checked_radio">
                <% var tmpIdx2=0 %>
                <% var tmpIdx3=0 %>
                <% _.each(obj, function(item){ %>
                <div class="info-detail-box clearfix" id="info-detail-box-<%=tmpIdx2%>">
                    <% _.each(item.categDetail, function(itemDetail){%>
                    <label for="detail-item-<%=tmpIdx3%>">
                        <input id="detail-item-<%=tmpIdx3%>" type="radio"
                               code="<%=itemDetail.code%>" txt="<%=itemDetail.txt%>" imgsrc="<%=itemDetail.imgsrc%>" name="banner_id" /><%=itemDetail.txt%></label>
                    <% tmpIdx3++ %>
                    <% });%></div>
                <% tmpIdx2++ %>
                <% });%></div>
            <div>
                <div id="modal-save-btn" class="btn btn-warn btn-w70x30 fr mt10 mb10">保存</div>
            </div>
        </div>

    </script>

    <script type="text/javascript" src="/assets/b2b/js/libs/jquery.validate.min.js"></script>
    <script src="/assets/b2b/js/libs/jquery.ajaxfileupload.js"></script>
    <script type="text/javascript" src="/assets/b2b/js/libs/dialog-min.js"></script>
    <script type="text/javascript" src="/assets/b2b/js/libs/editor/ueditor.config.js"></script>
    <script type="text/javascript" src="/assets/b2b/js/libs/editor/ueditor.all.js"></script>
    <script type="text/javascript" charset="utf-8" src="/assets/b2b/js/libs/editor/lang/zh-cn/zh-cn.js"></script>
    <script src="/assets/b2b/js/libs/messages_zh.js"></script>
    <script type="text/javascript">var ue = UE.getEditor('container');</script>

    <script src="/assets/b2b/js/pageModules/supplyer/S17.js"></script>

@stop